﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace cmsni.Account.orders
{
    public partial class edit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {




        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //if the query string is equal to zero then we only want a new record to be inserted 
            //on save 

            int id = Convert.ToInt32(Request.QueryString["id"]);
            if (id== 0)
            {
                using (var db = new cmsnistorefrontEntities())
                {
                    orderheader ord = new orderheader();
                    ord.telephone = "test";
                    db.orderheaders.Add(ord);
                    db.SaveChanges();

                }

            }
            else
            {


                using (var db = new cmsnistorefrontEntities())
                {
                  
                    var ord = db.orderheaders.FirstOrDefault(c => c.id == id);
                    ord.telephone = "am i updated";
                    db.SaveChanges();
                }
            }

        }
    }
}